package com.rbs.controller;

import com.rbs.service.Impl.PhoneServiceImpl;
import com.rbs.service.PhoneService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet(urlPatterns = "/DeletePhoneByIdController")
public class DeletePhoneByIdController extends HttpServlet {
    private PhoneService phoneService = new PhoneServiceImpl();
    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //接收客户端参数
        String strPid = request.getParameter("id");
        int pid = Integer.parseInt(strPid);
        int i = phoneService.deletePhoneById(pid);
        if (i > 0){
            response.sendRedirect(request.getContextPath()+"/FindAllPhoneController");
        }else {
            response.sendRedirect(request.getContextPath()+"/FindAllPhoneController");
        }
    }
}
